import Vue from 'vue';
import App from './App.vue';
import router from '@/router/index';
import '@/plugins/element';
import axios from 'axios';

// 导入全局样式表
import '@/assets/css/global.css';

// 导入字体图标
import '@/fonts/iconfont.css';

// 引用注册全局组件
import index from '@/utils/index';
Vue.use(index);

// 导入elementUI隐藏类
import '../node_modules/element-ui/lib/theme-chalk/display.css';

Vue.config.productionTip = false;

// 配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
axios.interceptors.request.use((config) => {
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
});
Vue.prototype.$http = axios;

new Vue({
  el: '#app',
  render: (h) => h(App),
  router,
  beforeCreate() {
    //安装全局事件总线，$bus就是当前应用的vm
    Vue.prototype.$bus = this;
  },
});
